package co.yixiang.modules.shop.mapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import co.yixiang.modules.shop.entity.YxInvestCart;
import co.yixiang.modules.shop.web.param.YxInvestCartQueryParam;
import co.yixiang.modules.shop.web.vo.YxInvestCartQueryVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.io.Serializable;

/**
 * <p>
 * 选购购物车表 Mapper 接口
 * </p>
 *
 * @author hisen
 * @since 2020-06-10
 */
@Repository
public interface YxInvestCartMapper extends BaseMapper<YxInvestCart> {

    @Select("select IFNULL(sum(cart_num),0) from yx_invest_cart " +
            "where is_pay=0 and is_del=0   and sid=#{sid} and type=#{type}")
    int cartSum(@Param("sid") int sid,@Param("type") String type);

    /**
     * 根据ID获取查询对象
     * @param id
     * @return
     */
    YxInvestCartQueryVo getYxStoreCartById(Serializable id);

    /**
     * 获取分页对象
     * @param page
     * @param yxInvestCartQueryParam
     * @return
     */
    IPage<YxInvestCartQueryVo> getYxStoreCartPageList(@Param("page") Page page, @Param("param") YxInvestCartQueryParam yxInvestCartQueryParam);

}
